<!-- banner查询 -->
<div class="search">
  <nz-select style="width:100px;margin-right: 5px;" [(ngModel)]="status" nzAllowClear nzPlaceHolder="使用状态"
    (ngModelChange)="searchData()">
    <nz-option *ngFor="let item of statuslist" [nzValue]="item.key" [nzLabel]="item.value"></nz-option>
  </nz-select>
  <nz-select style="width:100px;margin-right: 5px;" [(ngModel)]="type" nzAllowClear nzPlaceHolder="类别" (ngModelChange)="searchData()">
    <nz-option *ngFor="let item of typelist" [nzValue]="item.key" [nzLabel]="item.value"></nz-option>
  </nz-select>
  <nz-input-group nzSuffixIcon="anticon anticon-search" style="width:60%;margin-left:1rem;">
    <input type="text" nz-input placeholder="输入名称查询" [(ngModel)]="title" (keyup.enter)="searchData()">
  </nz-input-group>
  <a (click)="searchData()">查询</a>
  <a (click)="add()">添加</a>
</div>

<nz-table #ajaxTable nzShowSizeChanger [nzFrontPagination]="false" [nzData]="dataSet" [nzLoading]="loading" [nzTotal]="total"
  [nzShowTotal]="totalTemplate" [(nzPageIndex)]="pageIndex" [(nzPageSize)]="pageSize" (nzPageIndexChange)="searchData()"
  (nzPageSizeChange)="searchData(true)" [nzScroll]="{ x:'900px',y: '400px' }">
  <thead>
    <tr>
      <th nzWidth="60px" nzLeft="0px">序号</th>
      <th nzWidth="80px">名称</th>
      <th nzWidth="80px">使用状态</th>
      <th nzWidth="80px">类别</th>
      <th nzWidth="80px">是否上传图片</th>
      <th nzWidth="80px">外部链接</th>
      <th nzWidth="80px">序号</th>
      <th nzWidth="100px">创建人</th>
      <th nzWidth="100px">创建时间</th>
      <th nzWidth="100px">修改时间</th>
      <th nzWidth="80px" nzRight="0px">操作</th>
    </tr>
  </thead>
  <tbody>
    <tr *ngFor="let data of ajaxTable.data;index as i">
      <td nzLeft="0px">{{i+1}}</td>
      <td>{{data.title}}</td>
      <td>{{data.status}}</td>
      <td>{{data.type}}</td>
      <td>{{data.isimg}}</td>
      <td>{{data.hrefurl}}</td>
      <td>{{data.order}}</td>
      <td>{{data.createuser}}</td>
      <td>{{data.createTime | date:"yyyy-MM-dd HH:mm"}}</td>
      <td>{{data.updateTime | date:"yyyy-MM-dd HH:mm"}}</td>

      <td nzRight="0px">
        <a *ngIf="data.status=='有效'" (click)="lock(data._id)">禁用</a>
        <a *ngIf="data.status!='有效'" (click)="open(data._id)">启用</a>
        <a (click)="edit(data._id)">编辑</a>
      </td>
    </tr>
  </tbody>
</nz-table>

<ng-template #totalTemplate let-total>
  共 {{total}} 条
</ng-template>
<nz-modal [(nzVisible)]="isVisible" nzTitle="首页设置" (nzOnCancel)="handleCancel()" (nzOnOk)="handleOk()" nzWrapClassName="vertical-center-modal"
  [nzMaskClosable]="false" nzWidth="800">
  <div style="margin-bottom: 16px;" class="scrollbar my-modal">
    <nz-input-group nzAddOnBefore="名称">
      <input type="text" nz-input [(ngModel)]="doc.title">
    </nz-input-group>
    <nz-input-group nzAddOnBefore="类别">
      <nz-select style="width: 100%;" nzPlaceHolder="请选择类别" nzAllowClear [(ngModel)]="doc.type">
        <nz-option *ngFor="let item of typelist" [nzLabel]="item.value" [nzValue]="item.key">
        </nz-option>
      </nz-select>
    </nz-input-group>
    <nz-input-group nzAddOnBefore="图片" id="nav">
      <nz-upload class="avatar-uploader" [nzAction]="action" nzName="file" nzListType="picture-card"
        [nzShowUploadList]="false" [nzBeforeUpload]="beforeUpload" (nzChange)="handleChange($event)">
        <ng-container *ngIf="!doc.img">
          <i nz-icon type="plus"></i>
          <div class="ant-upload-text">上传图片</div>
        </ng-container>
        <img *ngIf="doc.img" [src]="doc.img" class="avatar">
      </nz-upload>
    </nz-input-group>
    <nz-input-group nzAddOnBefore="外部链接">
      <input type="text" nz-input [(ngModel)]="doc.hrefurl">
    </nz-input-group>
    <nz-input-group nzAddOnBefore="序号">
      <input type="text" nz-input [(ngModel)]="doc.order">
    </nz-input-group>
  </div>